package lesson14;

public class Auction
{
	Car car;
	Person person;
	private int numberOfCars;
	private int numberOfMembers;
	private boolean isOpen;
	private boolean isScrapped;
	Car[] cars;
	Person[] persons;
	

	/*Auction(int numberOfCars, int numberOfMembers)
	{
		this.numberOfCars = numberOfCars;
		this.numberOfMembers = numberOfMembers;
	}
	
	void dealing(Person[] persons, Car[] cars)
	{
		open();
		generatorBuy(persons, cars);
		scrappCar(cars);
		totalInformation(cars);
		close();
	}
	
	void isBought(Car car) //if the car is bought
	{
		car.isAvaible = false;
	}
	
	void open() //opens the auction
	{
		this.isOpen = true;
		System.out.println("Let's burn some money");
	}
	
	void close() //closes the auction
	{
		this.isOpen = false;
		System.out.println("Bye Bye");
	}
	
	void scrappCar(Car[] car) // if the car is scrapped
	{
		for (Car i : car) {
			if(i.isAvaible)
				this.isScrapped = true;
				i.owner = null;
		}
	}

	void generatorBuy(Person[] persons, Car[] cars)
	{
		int indexPerson = 0;
		for (Car i : cars) {
			if(car.isAvaible)
			{
				for (Person j : persons) {
					int random = (int)Math.round(Math.random()+1);
					if(random == 1)
					{
						i.owner.name = persons[indexPerson].name;
						persons[indexPerson].numberOfBoughtCars++;
						indexPerson++;
						break;
					}
				}
			}
		}
	}

	public void totalInformation(Car[] cars)
	{
		for (int i = 0; i < cars.length; i++) {
			if(cars[i].owner != null)
				System.out.println(cars[i].model + "->" + cars[i].owner);
			else
				System.out.println(cars[i].model + "->" + "The red!");
		}
	}
	
	public int getNumberOfCars()
	{
		return this.numberOfCars;
	}
	
	public int getNumberOfMembers()
	{
		return this.numberOfMembers;
	}
	*/
}
